﻿function get-xml($path) {
    return [xml] [string]::join(”`n”, (gc $path))
}




<# 
    Parses fields of a Create-Statement
    Lines eg.: [ShipmentValueCurrency] [nvarchar](10) NULL,
    
    <?xml version="1.0" encoding="iso-8859-1"?>
    <BUP_VC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <VC_MAIN>
        <FUNKTION>PRINT</FUNKTION>
    
    
#>
function Parse([string] $path){
    if(!( Test-path $path) ){
	   write-host Directory $path is not available!
       return
    } 
    
    $filesToScan = gci -path "$path" -Recurse -force | where {$_.attributes -ne "Directory"} |  where {$_.extension -eq ".xml"}
    
    
    foreach($file in $filesToScan){
    
        $xml= get-xml $file.FullName
        if ($xml.BUP_VC.VC_MAIN.FUNKTION -eq "PRINT"){
            #$xml.BUP_VC.VC_SEND.SEND_HEAD.E_NAME1
            $xml.BUP_VC.VC_SEND.SEND_HEAD.E_LAND + "  " + $xml.BUP_VC.VC_SEND.SEND_HEAD.E_PLZ + "  " + $xml.BUP_VC.VC_SEND.SEND_HEAD.E_STNR
            
        }
       
    }
    
    
    
    
   #  $filesToScan 
    
}


Parse "D:\Projekte\Sendit\Monitor\Trunk\Source\SapClientModule\RequestSuit"
